<!-- 供配电 》 电能质量 -->

<template>
  <CommonBody class="ElecQuality" hasTree :tree="elec_tree" :field="elec_TREE_FIELD" initRoot @change="setOne">
    <template #header>
      <ParamTab />
    </template>

    <div v-if="param.tab === 'wave'">
      <WaveSearch />
      <WaveTable />
    </div>

    <div v-else>
      <UnbalanceSearch />
      <UnbalanceTable />
    </div>

    <WaveModal />

    <UnbalanceModal />
  </CommonBody>
</template>

<script>
// ============================== 导入依赖 ============================== //

import CORE from '@/CORE'
import store from './store'

// ============================== 导出组件 ============================== //

export default {
  /**
   * 名称定义 (实际使用名称)
   */
  name: 'ElecQuality',

  /**
   * 混入列表 (配置选项合并)
   */
  mixins: [CORE.mixStore(store)],

  /**
   * 组件导入 (Abc.vue + Abc/index.vue)
   */
  ...CORE.components(require.context('./', true, /vue$/)),

  /**
   * 监听属性 (深度 deep 首次 immediate)
   */
  watch: {
    /**
     * 监听结构树就绪
     */
    elec_readyTree(ready) {
      if (ready) {
        const { param, one, elec_treeMap, elec_tree, setOne } = this
        const chosen = one.id ? elec_treeMap[one.id] : elec_tree[0]
        param.treeId = chosen.id
        setOne(chosen)
      }
    },

    /**
     * 监听单项 ID
     */
    'one.id'(id) {
      this.wave_param.monitorPointSiteId = id
      this.wave_startList()

      this.unbalance_param.monitorPointSiteId = id
      this.unbalance_startList()
    },
  },
}
</script>

<style lang="scss">
@import './index.scss';
</style>
